﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SimpleModel.Context
{
    public interface IRepository
    {
        int ACount<TEntityType>() where TEntityType : class;
        IQueryable<TEntityType> GetAll<TEntityType>() where TEntityType : class;
        TEntityType FindOne<TEntityType>(params object[] keyValues) where TEntityType : class;
        IQueryable<TEntityType> FindByQuery<TEntityType>(Expression<Func<TEntityType, bool>> expressio) where TEntityType : class;

        IQueryable<TEntityType> Search<TEntityType>(Expression<Func<TEntityType, bool>> expression, bool asc,
            Expression<Func<TEntityType, object>> keySelector, int pageIndex, int pageSize, ref int total) where TEntityType : class;

        IQueryable<TEntityType> Search<TEntityType>(Expression<Func<TEntityType, bool>> expression, string orderString,
            int pageIndex, int pageSize, ref int total) where TEntityType : class;

        void AddOne<TEntityType>(TEntityType entity) where TEntityType : class;
        void AddMultiple<TEntityType>(List<TEntityType> entityList) where TEntityType : class;
        void UpdateOne<TEntityType>(TEntityType entity) where TEntityType : class;
        void DeleteOne<TEntityType>(TEntityType entity) where TEntityType : class;

        void DeleteMultiple<TEntityType>(Expression<Func<TEntityType, bool>> expression)
            where TEntityType : class;
        bool AddOneAndSave<TEntityType>(TEntityType entity) where TEntityType : class;
        bool AddMultipleAndSave<TEntityType>(List<TEntityType> entityList) where TEntityType : class;
        bool UpdateOneAndSave<TEntityType>(TEntityType entity) where TEntityType : class;
        bool UpdateOneAndSave<TEntityType>(TEntityType entity, bool updateAll, params string[] propertyNames) where TEntityType : class;
        bool DeleteOneAndSave<TEntityType>(TEntityType entity) where TEntityType : class;
        bool Save();
        int UpdateMultipleAndSave<TEntityType>(Expression<Func<TEntityType, bool>> queryExpression,
            Expression<Func<TEntityType, TEntityType>> updateExpression) where TEntityType : class;

        int DeleteMultipleAndSave<TEntityType>(Expression<Func<TEntityType, bool>> expression) where TEntityType : class;
    }
}
